#include "common.h"

extern int clear_tag(char *src);
char ID_str[41];
unsigned long int data_length=0;

void writefileaol(Mail_info *mail_info)
{
	char patternfrom[]="requests=%5B%7B%22From%22%3A%22(.+?)%22%2C%22To";
	char patternto[]="%22%2C%22To%22%3A%22(.+?)%22%2C%22Cc";
	char patterncc[]="%2C%22%2C%22Cc%22%3A%22(.+?)%22%2C%22Bcc";
	char patternbcc[]="%22%2C%22Bcc%22%3A%22(.+?)%22%2C%22Subject";
	char patternsubject[]="%22%2C%22Subject%22%3A%22(.+?)%22%2C%22RichBody";
	char patternsubject_2[]="%22%2C%22Subject%22%3A%22(.+?)%22%2C%22PlainBody";
	char patterncontent[] ="%22%2C%22PlainBody%22%3A%22(.+?)%22%2C%22RichEdit";

	memset(mail_info->from,0,MAX_FROM_LEN+1);
	regcompile_1(mail_info->mail_data, patternfrom, mail_info->from, MAX_FROM_LEN);
	convert_contents(mail_info->from);
	memset(mail_info->to,0,MAX_TO_LEN+1);
	regcompile_1(mail_info->mail_data, patternto, mail_info->to, MAX_TO_LEN);
	convert_contents(mail_info->to);
	memset(mail_info->cc,0,MAX_CC_LEN+1);
	int k=regcompile_1(mail_info->mail_data, patterncc, mail_info->cc, MAX_CC_LEN);
	if(k!=-1)
	{
		convert_contents(mail_info->cc);
	}
	memset(mail_info->bcc,0,MAX_BCC_LEN+1);
	k=regcompile_1(mail_info->mail_data, patternbcc,mail_info->bcc, MAX_BCC_LEN);
	if(k!=-1)
	{
		convert_contents(mail_info->bcc);
	}
	k=regcompile_1(mail_info->mail_data, patternsubject, mail_info->subject, MAX_SUBJ_LEN);
	if(k==-1)
	{
		regcompile_1(mail_info->mail_data, patternsubject_2, mail_info->subject, MAX_SUBJ_LEN);
	}
	regcompile_2(mail_info->mail_data, patterncontent, &mail_info->content);
	if (mail_info->content != NULL)
	{
		convert_contents(mail_info->content);
	}
        memset(mail_info->save_path,0,MAX_PATH_LEN + 1);
	create_dir(mail_info->save_path,"aol",mail_info->from);
        write_to_file(mail_info);
}

void analyse_aol_content(Mail_info *mail_info,char *data,unsigned int datalen,struct tcphdr *tcp,int is_b_s)
{
	unsigned long int seq=ntohl(tcp->seq);
	int off_seq=seq-mail_info->start_seq;
	int range;
	char http_ok_head[18]="HTTP/1.1 200 OK\r\n";
	
	if(is_b_s)
	{
		if(!mail_info->is_complished)
		{
			if (mail_info->mail_length == 0) 
			{
				mail_info->mail_length = 5000;
				mail_info->mail_data = (char *)malloc(5000);
				if(mail_info->mail_data==NULL)
				{
					delete(mail_info);
					return;
				}
				memset(mail_info->mail_data,0,5000);
				mail_info->start_seq = seq;
			}
			if(mail_info->mail_length == 5000) 
			{
				long len;
				char *tmp;
				len = get_http_length(data);
				if (len > 0) 
				{
					mail_info->mail_length += len;
					tmp = (char *)malloc(mail_info->mail_length);
					if(tmp ==NULL)
					{
						delete(mail_info);
						return ;
					}
					memset(tmp,0,mail_info->mail_length);
					memcpy(tmp,mail_info->mail_data,5000);
					free(mail_info->mail_data);
					mail_info->mail_data = tmp;
				}
			}
			off_seq = seq - mail_info->start_seq;
			range=off_seq+datalen;
			if(range>mail_info->mail_length)
			{
				delete(mail_info);
				return;
			}
			memcpy(mail_info->mail_data+off_seq,data,datalen);
		}
	}
	else 
	if(!strncmp(data,http_ok_head,15))
	{
		get_time(data, mail_info->sent_time);
		mail_info->is_complished = 1;
		writefileaol(mail_info);
		del_mail_node(mail_info);
	}
}

void analyse_aol_attach_content(Attach_info *attach_info,char *data,unsigned int datalen,struct tcphdr *tcp,int is_b_s,char *destMAC)
{
	unsigned  long int seq=ntohl(tcp->seq);
	int result=0;
        int off_seq;
        int data_seq;
        int flag = 0;
        char *p;
	char writepath[MAX_PATH_LEN] = {0};
	int  i=0;

	if(is_b_s)
	{
		if (strstr(data, "/aol-6/en-us/common/rpc/RPC.aspx?") && strstr(data, "&transport=iframe&") && strstr(data, "&a=SendMessage&"))
		{
			attach_info->recive_length = 0;
			char *p = strstr(data, "\r\nContent-Length: ");
			if (p == NULL)
			{
				attach_info->recive_length = 5000;
			}
			else
			{
				p += 18;
				while( *p != '\r') 
				{
					attach_info->recive_length = attach_info->recive_length * 10 + (*p - '0');
					p++;
				}
			}
		}
		else if(strstr(data,"------Web") && attach_info->recive_data == NULL)
		{
			char *p1;
			char *p2;
			p1 = NULL;
			p2 = NULL;
			
			if (attach_info->recive_length <= 0)
				return ;
			attach_info->recive_length += 1000;
			attach_info->recive_data = (char *)malloc(attach_info->recive_length);
			memset(attach_info->recive_data,0,attach_info->recive_length);
			p1 = strstr(data,"------");
			if(p1 == NULL)
				return;
			p2 = strstr(p1,"\r\n");
			memcpy(ID_str, p1, p2-p1);

			p1 = strstr(data,"------");
			if(p1 == NULL)
				return;
                        attach_info->start_seq = seq+p1-data;
			memcpy(attach_info->recive_data, p1, datalen-(p1-data));
		}
		else
		{
			if((attach_info->recive_data != NULL) && datalen)
			{
				off_seq = seq - attach_info->start_seq;
				if (off_seq+ datalen <= attach_info->recive_length)
				{
					memcpy(attach_info->recive_data + off_seq, data, datalen);
				}
			}
		}
        }
	else
	{
		if(!attach_info->is_get_ok)
		{
			char http_ok_head[21]="HTTP/1.1 ";
			if(!strncmp(data,http_ok_head,9))
			{
				attach_info->is_get_ok=1;
				
				attach_info->is_complished =1;
				Mail_info *mail_info = (Mail_info *)malloc(sizeof(Mail_info));
				if (mail_info == NULL)
					return NULL;
				memset(mail_info, 0, sizeof(Mail_info));
				get_time(data, mail_info->sent_time);
				mail_info->source_ip = attach_info->source_ip;
				mail_info->dest_ip = attach_info->dest_ip;
				mail_info->source_port = attach_info->source_port;
				mail_info->dest_port = attach_info->dest_port;
				memcpy(mail_info->client_mac, destMAC, MAC_LEN);
				mail_info->is_complished = 1;
				mail_info->mail_type = attach_info->attach_type;
				mail_info->mail_length = 0;
				mail_info->mail_data = NULL;
				mail_info->is_writing = 0;
				mail_info->recive_length = 0;
				mail_info->recive_data = NULL;
				mail_info->connect_id[0]=0;
				mail_info->mail_id = (char *)malloc(MAX_ID_LEN);
				memset(mail_info->mail_id, 0, MAX_ID_LEN);
				mail_info->is_proce_mail = 0;
				mail_info->num_of_attach = 0;
				mail_info->start_seq = attach_info->start_seq;
				mail_info->prev = mail_tab.head;
				mail_info->next = mail_tab.head->next;
				mail_tab.head->next = mail_info;
				mail_info->mail_num= 312;
				strcpy(mail_info->url, "mail.aol.com");

				char from_str[90];
				strncpy(from_str, ID_str, 40);
				from_str[40]=0;
				strncat(from_str,"\r\nContent-Disposition: form-data; name=\"requests\"",49);
				char *p_from=memfind(attach_info->recive_data, from_str, attach_info->recive_length-1000);
				char patternfrom[]="\r\n\r\n\\[\\{\"From\":\"(.+?)\",\"To";
				regcompile_1(p_from, patternfrom, mail_info->from,MAX_FROM_LEN);
				memset(mail_info->save_path,0,MAX_PATH_LEN + 1);
				create_dir(mail_info->save_path,"aol",mail_info->from);

				while(attach_info->recive_data != NULL)
				{
					char *p1=strstr(attach_info->recive_data,"; filename=\"");
					if(p1 != NULL)
					{
						p1+=12;
						char *p2=strstr(p1,"\"\r\n");
						if(p2 == NULL)
							return;
						int len = p2 - p1;
						if(len>0)
						{
							i++;
							strncpy(attach_info->attach_name,p1,p2-p1);//the name of attach file
							attach_info->attach_name[p2-p1]=0;

							p1=strstr(p1,"\r\n\r\n");
							p1+=4;
							char str[43] = "\r\n";
							strncat(str,ID_str,40);
							p2 = memfind(p1, str, attach_info->recive_length-(p1-attach_info->recive_data)-1000);
							if(p2 == NULL)
								return ;
							struct timeval tv;
							struct timezone tz;
							gettimeofday(&tv,&tz);
							sprintf(attach_info->path_of_here,"%s/%lu-%lu",mail_temp_path,tv.tv_sec,tv.tv_usec); 
							mode_t  file_mode = S_IRUSR |S_IWUSR|S_IRGRP|S_IROTH;
							int fd = open(attach_info->path_of_here,O_RDWR|O_CREAT,file_mode);
							if (fd ==-1)
								return ;
							write(fd,p1,p2-p1);
							close(fd);
							Attachment *attachment = (Attachment *)malloc((sizeof(Attachment))+1);
							memset(attachment,0,(sizeof(Attachment))+1);
							memset(attachment->loc_filename,0,MAX_FN_LEN+1);
							attachment->next =NULL;
							snprintf(attachment->loc_name, MAX_FN_LEN, "%s", attach_info->attach_name);
							snprintf(attachment->loc_filename, MAX_FN_LEN, "attach%d", i);
							if(!flag)
							{
								mail_info->attach = attachment;
								flag++;
							}
							else
							{
								attachment->next =mail_info->attach->next;
								mail_info->attach->next=attachment;
							}
							sprintf(writepath,"%s/%s",mail_info->save_path,attachment->loc_filename);
							link(attach_info->path_of_here,writepath);
							unlink(attach_info->path_of_here);
						}
						attach_info->recive_data = strstr(p2,ID_str);
					}
					else
					{
						mail_info->num_of_attach = i;
						char patternto[]="To\":\"(.+?)\",\"Cc";
						char patterncc[]="Cc\":\"(.+?)\",\"Bcc";
						char patternbcc[]="Bcc\":\"(.+?)\",\"Subject";
						char patternsubject[]="Subject\":\"(.+?)\",\"RichBody";
						char patternsubject_2[]="Subject\":\"(.+?)\",\"PlainBody";
						char patterncontent[] = "PlainBody\":\"(.+?)\",\"RichEdit";
						regcompile_1(attach_info->recive_data, patternto, mail_info->to,MAX_TO_LEN);
						memset(mail_info->cc,0,MAX_CC_LEN);
						regcompile_1(attach_info->recive_data, patterncc,mail_info->cc,MAX_CC_LEN);
						memset(mail_info->bcc,0,MAX_BCC_LEN);
						regcompile_1(attach_info->recive_data, patternbcc,mail_info->bcc,MAX_BCC_LEN);
						int k = regcompile_1(attach_info->recive_data, patternsubject, mail_info->subject,MAX_SUBJ_LEN);
						if(k==-1)
						{
							regcompile_1(attach_info->recive_data, patternsubject_2, mail_info->subject,MAX_SUBJ_LEN);
						}
						regcompile_2(attach_info->recive_data, patterncontent, &mail_info->content);
						if (mail_info->content != NULL)
						{
							char *tmp_str;
							tmp_str = clear_html_tag(mail_info->content);
							free(mail_info->content);
							mail_info->content = tmp_str;
							tmp_str = NULL;
						}
						write_to_file(mail_info);
						attach_info->recive_data = NULL;
					}
				}
			}
		}
	}
}

int write_aol_recive_up(Mail_info *mail_info)
{
	int len;
	char *ungzip = NULL;
	decomp_gzip_1(mail_info->mail_data,mail_info->recive_length-2,&ungzip);
	if(ungzip==NULL)
		return;
	free(mail_info->mail_data);
	mail_info->mail_data = ungzip;
	char *p2;
	char *p1=strstr(ungzip,"replyAllCcAddrs\":\"");
	p1+=18;
	p2=strstr(p1,"\",\"isSuccess");
	len = p2 - p1;
	if(len>0)
	{
		strncpy(mail_info->cc,p1,len);
		mail_info->cc[len]=0;printf("\ncc %s\n",mail_info->cc);
		clear_tag(mail_info->cc);
		down_contents(mail_info->cc);printf("\ncc = %s\n",mail_info->cc);
	}

	p1=strstr(p1,"baseSubject\":\"");
	if(p1==NULL)
		return;
	p1+=14;
	p2=strstr(p1,"\",\"attachments");
	len=p2-p1;
	if(len>MAX_SUBJ_LEN) 
		len=MAX_SUBJ_LEN;
	strncpy(mail_info->subject,p1,len);
	mail_info->subject[len]=0;
	clear_tag(mail_info->subject);

	p1=strstr(p1,"displayTo\":\"");
	if(p1==NULL)
		return;
	p1+=12;
	p2=strstr(p1,"\",\"sentTime");
	len=p2-p1;
	if(len>MAX_FROM_LEN) 
		len=MAX_FROM_LEN;
	strncpy(mail_info->to,p1,len);
	mail_info->to[len]=0;
	clear_tag(mail_info->to);
	down_contents(mail_info->to);printf("\nmail_info->to = %s\n",mail_info->to);
	char *to = conv_to_xml_symbol(mail_info->to);printf("\nto = %s\n",to);
	strcpy(mail_info->to,to);

	char sendtime[100];
        memset(sendtime,0,100);
	p1=strstr(p1,"sentTime\":\"");
	p1+=11;
	p2=strstr(p1," +0000\",");
	len=p2-p1;
	strncpy(sendtime,p1,len);
	sendtime[len]=0;
	get_send_time(sendtime,mail_info->sent_time);

	p1 = ungzip;
	p1=strstr(p1,"displayBcc\":\"");
	p1+=13;
	p2=strstr(p1,"\",\"receivedTime");
	len = p2-p1;
	if(len>0)
	{
		strncpy(mail_info->bcc,p1,len);
		mail_info->bcc[len]=0;
		clear_tag(mail_info->bcc);
		down_contents(mail_info->bcc);
	}

	p1=strstr(p1,"uid\":\"");
	if(p1==NULL)
		return -1;
	p1+=6;
	p2=strstr(p1,"\",\"hasAttachments");
	if(p2==NULL)
		return -1;
	len=p2 - p1;
	if (len < 0 || len > MAX_ID_LEN)
		return -1;
	memcpy(mail_info->mail_id, p1, len);
	mail_info->mail_id[len] = 0;

	if(p1==NULL)
		p1=ungzip;
	p1=strstr(p1,"displayFrom\":\"");
	if(p1==NULL)
		return;
	p1+=14;
	p2=strstr(p1,"\",\"subject");
	len=p2-p1;
	if(len>MAX_FROM_LEN) 
		len=MAX_FROM_LEN;
	strncpy(mail_info->from,p1,len);
	mail_info->from[len]=0;
	clear_tag(mail_info->from);
	down_contents(mail_info->from);
	char patternfrom[]="<(.*)>";
	regcompile_1(mail_info->from, patternfrom, mail_info->from,100);

	p1=strstr(p1,"body\":\"");
	if(p1==NULL)
		return;
	p1+=7;
	p2=strstr(p1,"\",\"inputFrom");
	len=p2-p1;
	mail_info->content=(char *)malloc(len+1);
	strncpy(mail_info->content,p1,len);
	mail_info->content[len]=0;
	mail_info->content=clear_html_tag(mail_info->content);
	clear_tag(mail_info->content);
	down_contents(mail_info->content);
	mail_info->content=clear_html_symbol(mail_info->content);
	memset(mail_info->save_path,0,MAX_PATH_LEN + 1);
	create_dir(mail_info->save_path,"aol",mail_info->to);
	write_to_file(mail_info);
}

int analyse_aol_recive(Mail_info *mail_info,char *data,unsigned int datalen,struct tcphdr *tcp ,int is_b_s)
{
	unsigned int seq=ntohl(tcp->seq);
	int off_seq;
	int len;
	int range;
	char *p=NULL;
	if(is_b_s)
	{
	        if(strstr(data, "/aol-6/en-us/common/rpc/RPC.aspx?") && strstr(data, "&transport=xmlhttp&") && strstr(data, "&a=GetMessage&"))
	        {
			data_length = 0;
                        mail_info->is_writing = 0;
		}
	}
        if(!is_b_s)
        {
                if(datalen > 0)
                {
			char Data[16];
                	strncpy(Data,data,15);
                	Data[15]=0;
                }
                if(!strncmp(data,"HTTP/1.",7) && !mail_info->is_writing)
		{
			mail_info->mail_length=get_http_length(data);
			if(mail_info->mail_length>0)
			{
				mail_info->mail_data=(char *)malloc(mail_info->mail_length+20);
				if(mail_info->mail_data==NULL)
					return -1;
				p=strstr(data,"\r\n\r\n");
				if(p==NULL)
					return -1;
				p+=4;
				len=datalen-(p-data);
				mail_info->start_seq=seq+datalen;
				mail_info->source_seq=seq+(p-data);
				if(len>mail_info->mail_length)
					return -1;
				memset(mail_info->mail_data,0,mail_info->mail_length+1);
				memcpy(mail_info->mail_data,p,len);
				data_length += len;
				mail_info->recive_length = mail_info->mail_length;
				mail_info->is_writing = 1;
			}
                }
		else if(strncmp(data,"HTTP/1.",7) && !mail_info->is_writing)
		{
			mail_info->mail_length=get_http_length(data);
			if(mail_info->mail_length>0)
			{
				mail_info->mail_data=(char *)malloc(mail_info->mail_length+20);
				if(mail_info->mail_data==NULL)
					return -1;
				p=strstr(data,"\r\n\r\n");
				if(p==NULL)
					return -1;
				p+=4;
				len=datalen-(p-data);
				mail_info->start_seq=seq+datalen;
				mail_info->source_seq=seq+(p-data);
				if(len>mail_info->mail_length)
					return -1;
				memset(mail_info->mail_data,0,mail_info->mail_length+1);
				memcpy(mail_info->mail_data,p,len);
				data_length += len;
				mail_info->recive_length = mail_info->mail_length;
				mail_info->is_writing = 1;
			}
		}
                else if(mail_info->is_writing)
                {
			if(mail_info->mail_data == NULL)
				return;
			if( seq > mail_info->source_seq + mail_info->mail_length)
				return;
			else
			{
				if( seq + datalen > mail_info->source_seq + mail_info->mail_length)
				{
					memcpy(mail_info->mail_data+seq-mail_info->source_seq,data,mail_info->source_seq + mail_info->mail_length - seq);
					data_length += mail_info->source_seq + mail_info->mail_length - seq;
				}
				if( seq + datalen <= mail_info->source_seq + mail_info->mail_length)
				{
					memcpy(mail_info->mail_data+seq-mail_info->source_seq,data,datalen);
					data_length += datalen;
				}
			}
                }
                if(mail_info->mail_data == NULL)
                       return;
		if(tcp->fin || data_length == mail_info->mail_length)//接受结束
                {
			write_aol_recive_up(mail_info);
			del_mail_node(mail_info);
		}
        }
}

int analyse_aol_attach_recive(Mail_info *mail_info, char *data, unsigned int datalen, struct tcphdr *tcp, int is_b_s)
{
	unsigned long seq=ntohl(tcp->seq);
	int off_seq=seq-mail_info->start_seq;
	int range;
	unsigned int attach_len;
	int n;
	
	if (is_b_s)
	{
		char tmp_id[MAX_ID_LEN+1];
		int result;

		if (strstr(data, "/aol-6/en-us/mail/get-attachment.aspx?") && strstr(data, "&folder=Inbox&"))
		{
			char *p1, *p2;
			int len_id;
			p1=strstr(data,"?uid=");
			if(p1==NULL)
				return -1;
			p1+=5;
			p2=strstr(p1,"&folder=");
			if(p2==NULL)
				return -1;
			len_id=p2 - p1;
			if (len_id < 0 || len_id > MAX_ID_LEN)
				return -1;
			memcpy(mail_info->mail_id, p1, len_id);
			mail_info->mail_id[len_id] = 0;
			data_length = 0;
			mail_info->is_writing = 0;
			mail_info->mail_length = 0;
		}
	}
	else
	{
		if (!strncmp(data,"HTTP/1.1 200 OK\r\n",15))
		{
			char *p1 = strstr(data,"HTTP/1.1");
			char *p2 = strstr(data,"\n\r\n");
			if(p2!=NULL)
			{
				p2+=3;
				mail_info->mail_length=p2-p1;
				mail_info->mail_data=(char *)malloc(mail_info->mail_length);
				memcpy(mail_info->mail_data,p1,mail_info->mail_length);
				mail_info->recive_length=get_http_length(data);
				if(mail_info->recive_length<=0)
					return -1;
				mail_info->recive_length += 1000;
				mail_info->recive_data = (char *)malloc(mail_info->recive_length);
				if(mail_info->recive_data == NULL)
					return -1;
				memset(mail_info->recive_data,0,mail_info->recive_length);
				mail_info->http_seq = seq;
				mail_info->is_writing = 1;
			}
			else
			{
				mail_info->mail_data=(char *)malloc(datalen);
				memcpy(mail_info->mail_data,p1,datalen);
				mail_info->mail_length=datalen;
				data_length += datalen;
			}
		}
		else if(strncmp(data,"HTTP/1.1 200 OK\r\n",15) && mail_info->recive_data ==NULL)
		{
			char *p2 = strstr(data,"\n\r\n");
			if(p2!=NULL)
			{
				p2+=3;
				int len = p2-data;
				mail_info->mail_data=(char *)realloc(mail_info->mail_data,mail_info->mail_length+len);
				memcpy(mail_info->mail_data,data,len);
				mail_info->mail_length += len;
				mail_info->recive_length=get_http_length(data);
				if(mail_info->recive_length<=0)
					return -1;
				mail_info->recive_length += 1000;
				mail_info->recive_data = (char *)malloc(mail_info->recive_length);
				if(mail_info->recive_data == NULL)
					return -1;
				memset(mail_info->recive_data,0,mail_info->recive_length);
				mail_info->http_seq = seq;
				mail_info->is_writing = 1;
			}
			else
			{
				mail_info->mail_data=(char *)realloc(mail_info->mail_data,mail_info->mail_length+datalen);
				memcpy(mail_info->mail_data,data,datalen);
				data_length += datalen;
				mail_info->mail_length += datalen;
			}
		}
		if (mail_info->recive_data !=NULL)
		{
			off_seq = seq - mail_info->http_seq;
			if(off_seq < 0)
				return -1;
			range = off_seq + datalen;
			if (range >= mail_info->recive_length)
				return -1;
			memcpy(mail_info->recive_data+off_seq,data,datalen);
			data_length += datalen;
		}
		if (data_length-mail_info->mail_length == mail_info->recive_length-1000 && mail_info->is_writing)
		{
			mail_info->is_complished = 1;
			attach_len=get_http_length_2(mail_info->mail_data,&n);
			if (attach_len <= 0)
				return -1;
			write_attach_down_3(mail_info,attach_len,n);
			del_mail_node(mail_info);
		}
	}
}

void analyse_aol(void *tmp,char *data,unsigned int datalen,struct tcphdr *tcp,int is_b_s,int m_or_a,char *destMAC)
{
	Mail_info *mail_info;
	Attach_info *attach_info;
	unsigned int type;
	int result=0;
	if(!m_or_a)
	{
		mail_info=(Mail_info *)tmp;
		type=mail_info->mail_type;
		type = type & 0X00FF;
		switch(type)
		{
			case 0x11:
				analyse_aol_content(mail_info,data,datalen,tcp,is_b_s);
				break;
			case 0x31:
				result=analyse_aol_recive(mail_info,data,datalen,tcp,is_b_s);
                                if(result==-1)
					delete(mail_info);
				break;
			case 0x32:
				result=analyse_aol_attach_recive(mail_info,data,datalen,tcp,is_b_s);
				if(result == -1)
					delete(mail_info);
				break;
			default:
				break;
		}
	}
	else
	{
	        attach_info=(Attach_info *)tmp;
		type=attach_info->attach_type;
		type = type & 0x00FF;
		switch(type) 
		{
			case 0x61:
				analyse_aol_attach_content(attach_info,data,datalen,tcp,is_b_s,destMAC);
				break;
			default :
				break;
		}
	}
}